<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="ctx" th:content="@{/}" />
  <title>AdminLTE 2 | Log in</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta name="viewport"
        content="width=device-width,user-scalable=no,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,initial-scale=1"/>

  <link rel="stylesheet"
        th:href="@{/thirdParty/bootstrap/css/bootstrap.min.css}"/>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css"/>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css"/>
  <link rel="stylesheet"  th:href="@{/thirdParty/dist/css/AdminLTE.min.css}" />
  <link rel="stylesheet"  th:href="@{/thirdParty/iCheck/square/blue.css}"/>

</head>
<body class="hold-transition login-page">
<div class="login-box">
  <div class="login-logo">
    <a href="../../index2.html"><b>汇贝送水</b>后台</a>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body">
    <p class="login-box-msg">Sign in to start your session</p>

    <form role="form" id="loginForm" th:action="@{/admin/account/login}" method="post">
      <div class="form-group has-feedback">
        <input type="email" class="form-control" id="email" name="email" placeholder="请输入账户" required="required"/>
        <span class="glyphicon glyphicon-user form-control-feedback"></span>
      </div>
      <div class="form-group has-feedback">
        <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码" required="required"/>
        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
      </div>
      <div class="row">
        <div class="col-xs-8">
          <div class="checkbox icheck">
            <label>
              <input type="checkbox" /> 记住我
            </label>
          </div>
        </div>
        <!-- /.col -->
        <div class="col-xs-4">
          <button type="button" class="btn btn-primary btn-block btn-flat" onclick="signIn();">登 录</button>
        </div>
        <!-- /.col -->
      </div>
    </form>
    <!-- /.social-auth-links -->
    <!--
    <a  href="javascript:void(0);" onclick="forgetPas();">I forgot my password</a><br />
    <a  th:href="@{/admin/account/registerPage}" class="text-center">Register a new membership</a>
    -->

  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<script th:src="@{/thirdParty/jQuery-2.2.0.min.js}"></script>
<script th:src="@{http://cdn.bootcss.com/bootbox.js/4.3.0/bootbox.min.js}"></script>
<script th:src="@{/thirdParty/bootstrap/js/bootstrap.min.js}"></script>
<script th:src="@{/thirdParty/jquery.form.js}"></script>
<script th:src="@{/thirdParty/iCheck/icheck.min.js}" />
<script th:src="@{/thirdParty/md5.js}" />
<script>
  var ctx = $("meta[name='ctx']").attr("content");
  $(function () {

    $('input').iCheck({
      checkboxClass: 'icheckbox_square-blue',
      radioClass: 'iradio_square-blue',
      increaseArea: '20%' // optional
    });
   /* $('#loginForm').ajaxForm({
      beforeSubmit: function() {
        var pd = $('input[name="password"]').val();
        pd = calcMD5(pd,32);
        $('input[name="password"]').val(pd);
        return false;
      },
      success : function(data){
        var result = data.trim();
        if (result == 'success') {
          var name = $('#email').val();

          window.location.href=ctx+"admin/account/main";
        } else {
          $("p.login-box-msg").html(result);
        }
      }
    });*/



    function forgetPas(){
        alert("忘了就忘了吧~~")
    }

  });

  function signIn() {
    var email = $("#email").val();
    var password = $("#password").val();
    password = calcMD5(password,32);
    $.ajax({type:"post",
      url:ctx+"admin/account/login",
      data:{email:email,password:password},
      dataType:"text",
      error: function(){
        alert("系统忙，请稍后再试！");
      },
      success:function(data){
        var result = data.trim();
        if (result == 'success') {
          var name = $('#email').val();

          window.location.href=ctx+"admin/account/main";
        } else {
          $("p.login-box-msg").html(result);
        }
      }
    });
  }

</script>
</body>
</html>
